//商品展示页，增加瀑布流商品在容器中
    //瀑布流实现函数

function checkScrollDirector() {      //判断滚动条是否滑到底部
    var flag = 0;
    if ($(document).scrollTop() + $(window).height() >= $(document).height()) {
        flag = 1;
    }
    return flag;
}

//通过ajax方式获取商品数据并写入
var start=0;
function getData() {
    $.ajax({
        type:"get",
        url: "/common/goods/list",
        contentType:"application/json;charset=UTF-8",
        dataType:"json",
        // data:data,
        success(res){
            console.log(res.msg)
            if(2000==res.code){
                var goods=res.data.goods
                var goods_name=goods[0].goodsName
                console.log(goods);
                console.log(goods_name)

                var json=goods
                var i=start
                console.log(i)
                var html = "<div class='box'><div class='boximg'>" +
                                "<img src=" + json[i].imgPath + "><br>" +
                                "<span>"+json[i].goodsName+"</span><br>" +
                                "<span class='storePrice'>门店价格："+json[i].storePrice+"</span><br>" +
                                "<span class='price'>现在团购仅需："+json[i].price+"</span></div></div>" +
                                "<div class='box'><div class='boximg'>" +
                                "<img src=" + json[i+1].imgPath + "><br>" +
                                "<span>"+json[i+1].goodsName+"</span><br>" +
                                "<span class='storePrice'>门店价格："+json[i+1].storePrice+"</span><br>" +
                                "<span class='price'>现在团购仅需："+json[i+1].price+"</span></div></div>" +
                                "<div class='box'><div class='boximg'>" +
                                "<img src=" + json[i+2].imgPath + "><br>" +
                                "<span>"+json[i+2].goodsName+"</span><br>" +
                                "<span class='storePrice'>门店价格："+json[i+2].storePrice+"</span><br>" +
                                "<span class='price'>现在团购仅需："+json[i+2].price+"</span></div></div>" +
                            "<div class='box'><div class='boximg'>" +
                                "<img src=" + json[i+3].imgPath + "><br>" +
                                "<span>"+json[i+3].goodsName+"</span><br>" +
                                "<span class='storePrice'>门店价格："+json[i+3].storePrice+"</span><br>" +
                                "<span class='price'>现在团购仅需："+json[i+3].price+"</span></div></div><div class='clear'></div>";
                $("#container").append(html);
                start +=4
            }
        }
    })
}

window.onscroll = function () {//滚动条滚动执行
    if (checkScrollDirector()) {
            getData()
    }
}






